asm
  ld sp,$C7FF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $C012
dim seed as uinteger at $C014
dim ee0 as uinteger at $C024
dim ee1 as uinteger at $C026
dim ee2 as uinteger at $C016
dim ee3 as uinteger at $C018
dim ex0 as uinteger at $C020
dim ey0 as uinteger at $C022

sub markhamputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $D001+txp1*64+typ1*2,tch1
  poke $D000+txp1*64+typ1*2,tat1
  end sub


for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    markhamputchar(ee1,ee0,seed band 7,ee2)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    markhamputchar(ee1+14,ee0+13,ee0*16+ee1,0)
    next:next

eee=0:ex0=8:ey0=8
do

markhamputchar(2,3,48+((int(eee/10000)) mod 10),0)
markhamputchar(3,3,48+((int(eee/1000)) mod 10),0)
markhamputchar(4,3,48+((int(eee/100)) mod 10),0)
markhamputchar(5,3,48+((int(eee/10)) mod 10),0)
markhamputchar(6,3,48+(eee mod 10),0)

ee0=peek($E000)
markhamputchar(4,5,48+((int(ee0/100)) mod 10),0)
markhamputchar(5,5,48+((int(ee0/10)) mod 10),0)
markhamputchar(6,5,48+(ee0 mod 10),0)

ee0=peek($E001)
markhamputchar(4,6,48+((int(ee0/100)) mod 10),0)
markhamputchar(5,6,48+((int(ee0/10)) mod 10),0)
markhamputchar(6,6,48+(ee0 mod 10),0)

ee0=peek($E002)
markhamputchar(4,7,48+((int(ee0/100)) mod 10),0)
markhamputchar(5,7,48+((int(ee0/10)) mod 10),0)
markhamputchar(6,7,48+(ee0 mod 10),0)

ex0=ex0+((ee0 band 1)/1)-((ee0 band 2)/2)
ey0=ey0+((ee0 band 8)/8)-((ee0 band 4)/4)
markhamputchar(ex0,ey0,eee band 127,0)

ee0=peek($E003)
markhamputchar(4,8,48+((int(ee0/100)) mod 10),0)
markhamputchar(5,8,48+((int(ee0/10)) mod 10),0)
markhamputchar(6,8,48+(ee0 mod 10),0)

eee=eee+1
loop




do:loop



for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    markhamputchar(ee1,ee0,seed,ee2)
    pacmandelay(2000)
    next:next

do:loop



for eee=$D001 to $D7FF step 2
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next

do:loop






do
for eee=$C800 to $CFFF
  seed=smsrnd(seed)
  poke eee,seed
  next
for eee=$D000 to $D7FF
  seed=smsrnd(seed)
  poke eee,seed
  next
loop

'static ADDRESS_MAP_START( markham_master_map, AS_PROGRAM, 8, markham_state )
'AM_RANGE(0x0000, 0x5fff) AM_ROM
'AM_RANGE(0xc000, 0xc7ff) AM_RAM
'AM_RANGE(0xc800, 0xcfff) AM_RAM AM_SHARE("spriteram")
'AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(markham_videoram_w) AM_SHARE("videoram")
'AM_RANGE(0xd800, 0xdfff) AM_RAM AM_SHARE("share1")
'AM_RANGE(0xe000, 0xe000) AM_READ_PORT("DSW2")
'AM_RANGE(0xe001, 0xe001) AM_READ_PORT("DSW1")
'AM_RANGE(0xe002, 0xe002) AM_READ_PORT("P1")
'AM_RANGE(0xe003, 0xe003) AM_READ_PORT("P2")
'AM_RANGE(0xe004, 0xe004) AM_READ(markham_e004_r) /* from CPU2 busack */
'AM_RANGE(0xe005, 0xe005) AM_READ_PORT("SYSTEM")
'AM_RANGE(0xe008, 0xe008) AM_WRITENOP /* coin counter? */
'AM_RANGE(0xe009, 0xe009) AM_WRITENOP /* to CPU2 busreq */
'AM_RANGE(0xe00c, 0xe00d) AM_WRITEONLY AM_SHARE("xscroll")
'AM_RANGE(0xe00e, 0xe00e) AM_WRITE(markham_flipscreen_w)
'ADDRESS_MAP_END

'static ADDRESS_MAP_START( markham_slave_map, AS_PROGRAM, 8, markham_state )
'AM_RANGE(0x0000, 0x5fff) AM_ROM
'AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("share1")
'AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("sn1", sn76496_device, write)
'AM_RANGE(0xc001, 0xc001) AM_DEVWRITE("sn2", sn76496_device, write)
'AM_RANGE(0xc002, 0xc002) AM_WRITENOP /* unknown */
'AM_RANGE(0xc003, 0xc003) AM_WRITENOP /* unknown */
'ADDRESS_MAP_END



'-----------------------------------------
'sub pingpongputsprite(tlayer as ubyte,tx as ubyte,ty as ubyte,tid as ubyte,tclut as ubyte):
'  poke $9006+((tlayer band 15)*4),tx  '- x sprite 0
'  poke $9004+((tlayer band 15)*4),ty bxor 255  '- y sprite 0
'  poke $9005+((tlayer band 15)*4),tid          '- shape sprite 0
'  poke $9003+((tlayer band 15)*4),tclut        '- clut? sprite 0
'  end sub
'
'function test1(t1 as uinteger,t2 as uinteger,t3 as uinteger,t4 as uinteger)  as uinteger
'  end function
'
'sub zpoke(t1 as uinteger,t2 as ubyte)
'  poke t1,t2
'  end sub
'
'sub putchar(tx1 as uinteger, ty1 as uinteger, tch1 as uinteger)
'  poke ($8400+(tx1*32)+ty1) bxor %0000001111100000,(tch1 band 255)
'  end sub
'
'pingpongputsprite(0,21,10,4,3)
'pingpongputsprite(1,21,30,4,3)
'pingpongputsprite(2,21,50,4,3)
'pingpongputsprite(3,21,70,4,3)
'pingpongputsprite(4,21,90,4,3)
'pingpongputsprite(5,21,110,4,3)
'pingpongputsprite(6,21,130,4,3)
'pingpongputsprite(7,21,150,4,3)
'
'seed=0
'
'for ee2=64 to 1023-64
'  for ee3=1 to 100
'    poke $8400+ee2,$01
'    next:next
'
'ee4=0
'for ee2=3 to 3+15
'  for ee3=15 to 15+15
'    poke $8400+ee3+(ee2*32),ee4
'    ee4=ee4+1
'    next:next
'
'ee4=0
'for ee2=20 to 20+7
'  for ee3=15 to 15+15
'    poke $8400+ee3+(ee2*32),ee4 band 3
'    poke $8000+ee3+(ee2*32),int(ee4/4)
'    ee4=ee4+1
'    next:next
'
'
'
'
'for ee2=4 to 7
'  for ee3=2 to 5
'    poke $8400+ee3+(ee2*32),code("X")
'    next
'    next
'
'test1(377,2445,63888,2342)
'
'eee=$4207
'i=code("Q")
'poke eee,i
'eee=eee+1
'i=code("T")
'poke eee,i
'
'seed=0
'for eee=$4400 to $47FF
'  seed=smsrnd(seed)
'  poke eee,seed
'  next
'
'ex0=80:ey0=176
'
'eee=0
'ecsp=0:ecsq=0
'
'




